package com.peanut.mapper;

import com.orm.annotation.Delete;
import com.orm.annotation.Select;
import com.orm.mapper.BaseMapper;
import com.peanut.entity.RoleApi;

import java.util.List;

public interface RoleInterfaceMapper extends BaseMapper<RoleApi> {

	
	// 根据角色 id 删除相关记录
	@Delete("delete from role_api where role_id = #{roleId}")
	void deleteByRoleId(int roleId);
	
	
	
	// 根据角色id 查 所有权限id
	@Select("select api_url_id  from role_api where role_id = #{roleId}")
	List<Integer> queryApiUrlIdByRoleId(int roleId);
	
	
	// 根据角色id 查 所有权限url
	@Select("select a.api_url from api_url a join role_api r on r.api_url_id = a.id where r.role_id = #{roleId}")
	List<String> queryApiUrlByRoleId(int roleId);
	
	
	// 根据角色id 查所有url 接口地址
	@Select("select api_url from api_url where id in  \n" +
			"( select api_url_id from role_api where role_id = #{roleId} )")
	List<String> queryAllApiString(int roleId);
}
